cmake_minimum_required(VERSION 3.5)

project(gobj_build)

find_package(PkgConfig REQUIRED)

# 关闭弃用API警告
set(CMAKE_C_FLAGS "-Wno-error=deprecated-declarations -Wno-deprecated-declarations -DGLIB_DISABLE_DEPRECATION_WARNINGS")
SET(GLIB_PKG_PATH "/home/mikelucis/Program/TARGET/lib/x86_64-linux-gnu/pkgconfig")

# 搜索Glib库
set(ENV{PKG_CONFIG_PATH} ${GLIB_PKG_PATH})
pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_search_module(GOBJ REQUIRED gobject-2.0)

message(STATUS "glib-2.0 include dir: " ${GLIB_INCLUDE_DIRS})
message(STATUS "glib-2.0 lib dir: " ${GLIB_LIBRARY_DIRS})
message(STATUS "gobject-2.0 lib: " ${GOBJ_LIBRARIES})

# 定义库位置
include_directories(${GLIB_INCLUDE_DIRS})
link_directories(${GLIB_LIBRARY_DIRS})

# 引入子项目
add_subdirectory(gbDlist)
add_subdirectory(gbBook)
add_subdirectory(gbUsb)

# 主程序
add_executable(gobj_build main.c)

# 链接Glib库到程序
target_link_libraries(gobj_build PUBLIC gbDlist)
target_link_libraries(gobj_build PUBLIC gbBook)
target_link_libraries(gobj_build PUBLIC gbUsb)
target_link_libraries(gobj_build PUBLIC ${GOBJ_LIBRARIES})